﻿<sap:ActivityDesigner x:Class="Neovolve.Toolkit.Workflow.Design.Presentation.IfThenDesigner"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:s="clr-namespace:System;assembly=mscorlib"
                      xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
                      xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
                      xmlns:conv="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
                      xmlns:sadm="clr-namespace:System.Activities.Presentation.Model;assembly=System.Activities.Presentation"
                      xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
                      xmlns:ntw="clr-namespace:Neovolve.Toolkit.Workflow;assembly=Neovolve.Toolkit.Workflow"
                      xmlns:ntwd="clr-namespace:Neovolve.Toolkit.Workflow.Design">
	<sap:ActivityDesigner.Icon>
		<DrawingBrush>
			<DrawingBrush.Drawing>
				<ImageDrawing>
					<ImageDrawing.Rect>
						<Rect Location="0,0"
						      Size="16,16">
						</Rect>
					</ImageDrawing.Rect>
					<ImageDrawing.ImageSource>
						<BitmapImage UriSource="arrow_branch.png"></BitmapImage>
					</ImageDrawing.ImageSource>
				</ImageDrawing>
			</DrawingBrush.Drawing>
		</DrawingBrush>
	</sap:ActivityDesigner.Icon>
	<sap:ActivityDesigner.Resources>
		<conv:ArgumentToExpressionConverter x:Key="expressionConverter" />
		<DataTemplate x:Key="Collapsed">
			<TextBlock HorizontalAlignment="Center"
			           FontStyle="Italic"
			           Foreground="Gray">
				Double-click to view
			</TextBlock>
		</DataTemplate>
		<DataTemplate x:Key="Expanded">
			<StackPanel Orientation="Vertical">
				<TextBlock HorizontalAlignment="Left"
				           VerticalAlignment="Center"
				           Margin="3">
					Condition
				</TextBlock>
				<sapv:ExpressionTextBox Expression="{Binding Path=ModelItem.Condition, Converter={StaticResource expressionConverter}}"
				                        ExpressionType="s:Boolean"
				                        OwnerActivity="{Binding ModelItem}"
				                        Margin="3" />
				<TextBlock HorizontalAlignment="Left"
				           VerticalAlignment="Center"
				           Margin="3">
					Then
				</TextBlock>
				<sap:WorkflowItemPresenter Item="{Binding ModelItem.Body.Handler}"
				                           HintText="Drop activity"
				                           Margin="3" />
			</StackPanel>
		</DataTemplate>
		<Style x:Key="ExpandOrCollapsedStyle"
		       TargetType="{x:Type ContentPresenter}">
			<Setter Property="ContentTemplate"
			        Value="{DynamicResource Collapsed}" />
			<Style.Triggers>
				<DataTrigger Binding="{Binding Path=ShowExpanded}"
				             Value="true">
					<Setter Property="ContentTemplate"
					        Value="{DynamicResource Expanded}" />
				</DataTrigger>
			</Style.Triggers>
		</Style>
	</sap:ActivityDesigner.Resources>
	<Grid>
		<ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}"
		                  Content="{Binding}" />
	</Grid>
</sap:ActivityDesigner>